package com.lmy.mongodb.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.util.Date;

/**
 * 创建实体，对应mongodb 中 某个集合的一个文档
 */
@Document("employees")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Employee {

    //@Id映射文档中的_id
    @Id
    private Integer id;

    //@Field指定实体字段和mongodb字段的映射关系
    @Field("username")
    private String name;

    @Field
    private Integer age;

    @Field
    private Double salary;

    @Field
    private Date birthday;

}
